﻿@model string
@using PageAdmin.Utils;
@{
    string table = ViewBag.Table;
    string guid = Html.Guid();
    CurrentUser user = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList(table, action, user,PageAdmin.Common.FromEnum.Admin,true);
}
<div class="main">
    <script src="~/Incs/UEditor/ueditor.forAdmin.config.js" type="text/javascript"></script>
    <script src="~/Incs/UEditor/ueditor.all.min.js" type="text/javascript"></script>
    <form method="post" id="_form" class=" form-control-sm form ui-validForm" enctype="multipart/form-data" data-custom-params="beforeSubmit:'BeforeSubmit'" data-source="@Model">
        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("currentUser", ViewBag.CurrentUser);
            data.Add("from","admin");
            data.Add("i", 0);
            int i = 0;
            foreach (var row in fieldData)
            {
                data["i"] = i;
                beforeSubmitJs += row.BeforeSubmitJs;
                Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                i++;
            }
        }
        <div class="form-group">
            <div class="controls">
                <input type="hidden" name="ParentId" id="ParentId" value="" />
                <input type="hidden" name="ParentGuid" id="ParentGuid" value="" />
                <input type="hidden" name="Id" id="Id" value="0" />
                <input type="hidden" name="Guid" id="Guid" value="@guid" />
                <button type="button" class="btn btn-sm  btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl()',callBack:'PostBack'">提交</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
            </div>
        </div>
    </form>

</div>
<script type="text/javascript">
    var id = Request("id");
    if (IsInt(id))
    {
        $("#_form").FormBind({ dataSourceFrom: "attr" })
    }

    function BeforeSubmit() {
        @Html.Raw(beforeSubmitJs)
        return true;
    }
    //function PostBack() {
    //    //parent.location.href = parent.location.href;
    //    if (Request("id") == "") {
    //        location.href = location.href
    //    }
    //    parent.LoadData();
    //}

</script>